package cn.wolfcode.crm.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.github.pagehelper.PageInfo;

import cn.wolfcode.crm.domain.CustomerTransfer;
import cn.wolfcode.crm.query.CustomerTransferQueryObject;
import cn.wolfcode.crm.service.ICustomerTransferService;
import cn.wolfcode.crm.service.ISystemDictionaryItemService;
import cn.wolfcode.crm.util.RequiredPermission;

@Controller
@RequestMapping("/customerTransfer")
public class CustomerTransferController {
	@Autowired
	private ICustomerTransferService customerTransferService;
	
	@Autowired
	private ISystemDictionaryItemService systemDictionaryItemService;

	@RequiredPermission({"客户移交历史列表", "customerTransfer:list"})
	@RequestMapping("/list")
	public String list(@ModelAttribute("qo") CustomerTransferQueryObject qo, Model model) {
		PageInfo<CustomerTransfer> pageInfo = customerTransferService.list(qo);
		
		model.addAttribute("pageInfo", pageInfo);
		return "customerTransfer/list";
	}

	@RequiredPermission({"客户移交历史新增", "customerTransfer:saveOrUpdate"})
	@RequestMapping("/save")
	public String save(CustomerTransfer entity) {
		customerTransferService.save(entity);
		return "redirect:/customerTransfer/list.do";
	}
}
